'use strict';
module.exports = {
	/**
	 * 非常重要：H5推啊的创建订单
	 * XXXnameXXX
	 * @url client/pay/pub/h5pay 前端调用的url参数地址
	 * data 请求参数
	 * @param {String} params1  参数1
	 */
	main: async (event) => {
		let { data = {}, userInfo, util, filterResponse, originalParam } = event;
		let { customUtil, uniID, config, pubFun, vk, db, _ } = util;
		let { uid, subject, total_fee, bean_number, tuia } = data;
		let res = { code: 0, msg: "" };
		// 业务逻辑开始-----------------------------------------------------------
		let out_trade_no = vk.pubfn.createOrderNo("NO", 25);
		res.add_order = await db.collection('a_h5pay').add({
			openid: "未支付时无openid",
			out_trade_no: out_trade_no,
			subject: subject,
			total_fee: total_fee,
			bean_number: bean_number,
			state: 0, //核销状态，指该笔订单有没有充值到用户账户里
			pay_state: 0, //支付状态
			tuia: tuia, //推啊指定ID
			tuia2: "备用字段",
			time: new Date().getTime(),
			_add_time_str: vk.pubfn.timeFormat(new Date(), "yyyy-MM-dd hh:mm:ss"),
			remark: "已提交未支付"
		})

		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}
